/*
 *  Copyright 2004 Blandware (http://www.blandware.com)
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.blandware.atleap.model.core;

import java.util.Arrays;


/**
 * <p>Contains BLOB with resource data that corresponds to some content resource.</p>
 * <p><a href="ResourceData.java.html"><i>View Source</i></a>
 * </p>
 * <p/>
 *
 * @author Sergey Zubtsovskiy <a href="mailto:sergey.zubtsovskiy@blandware.com">&lt;sergey.zubtsovskiy@blandware.com&gt;</a>
 * @version $Revision: 1.15 $ $Date: 2006/08/05 17:01:54 $
 * @see ContentResource
 * @hibernate.class table="`al_core_resource_data`" lazy="true"
 */
public class ResourceData extends BaseObject {

	//~ Instance variables

    /**
     * The ID of this resource data
     */
	protected Long id;
    /**
     * Binary data
     */
	protected byte[] data;


	//~ Constructors

	/**
	 * Creates new instance of ResourceData
	 */
	public ResourceData() {
	}

	/**
	 * Creates new instance of ResourceData
	 *
	 * @param data Data itself
	 */
	public ResourceData(byte[] data) {
		this.data = data;
	}

	//~ Methods

	/**
	 * Returns the id of this resource data
	 *
	 * @return id
	 * @hibernate.id column="`id`"
	 * generator-class="increment" unsaved-value="null"
	 */
	public Long getId() {
		return id;
	}

    /**
     * Sets the id of this resource data
     *
     * @param id the id to set
     */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * Returns the binary data itself
	 *
	 * @return byte array representing binary data
	 * @hibernate.property type="com.blandware.atleap.persistence.hibernate.util.BinaryBlobType"
     * column="`raw_data`" not-null="true" unique="false"
     * length="${database.blob.size.max}"
	 */
	public byte[] getData() {
		return data;
	}

    /**
     * Sets the binary data itself
     *
     * @param data byte array representing binary data
     */
	public void setData(byte[] data) {
		this.data = data;
	}

	public boolean equals(Object o) {
		if ( this == o ) {
			return true;
		}
		if ( !(o instanceof ResourceData) ) {
			return false;
		}

		final ResourceData resourceData = (ResourceData) o;

		if ( !Arrays.equals(data, resourceData.data) ) {
			return false;
		}

		return true;
	}

	public int hashCode() {
		return 0;
	}

}
